import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '主键',
    align: 'center',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '工作角色名称',
    align: 'center',
    dataIndex: 'workName',
    editRow: true,
    editComponent: 'Input',
  },
  {
    title: '工作角色系数',
    align: 'center',
    dataIndex: 'workCode',
    editRow: true,
    editComponent: 'InputNumber',
  },
  {
    title: '是否默认',
    align: 'center',
    dataIndex: 'isDefault',
    customRender: ({ text }) => {
      return 'true' === text ? '是' : '否';
    },
    editRow: true,
    editComponent: 'Switch',
  },
  {
    title: '排序',
    align: 'center',
    dataIndex: 'displayOrder',
    editRow: true,
    editComponent: 'Input',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'orgCode',
    component: 'Select',
    label: '班组1',
    componentProps: {
      options: userStore.getTeamList,
    },
    defaultValue: userStore.getOrgCode,
    colProps: { span: 8, },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '工作系数类型',
    field: 'xsCode',
    component: 'Input',
  },
  {
    label: '工作系数名称',
    field: 'xsName',
    component: 'Input',
  },
  {
    label: '工作名称',
    field: 'workName',
    component: 'Input',
  },
  {
    label: '工作系数',
    field: 'workCode',
    component: 'Input',
  },
  {
    label: '是否默认 false-否 true-是',
    field: 'isDefault',
    component: 'Input',
  },
  {
    label: '排序',
    field: 'displayOrder',
    component: 'InputNumber',
  },
  {
    label: '描述',
    field: 'workDescription',
    component: 'Input',
  },
  {
    label: '班组编码',
    field: 'orgCode',
    component: 'Input',
  },
  {
    label: '班组名称',
    field: 'orgName',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}